<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">

	<ui:define name="content">
		<f:event type="preRenderView"
			listener="#{agentController.beforeEditAgent}" />

		<div class="title ui-widget-header ui-corner-all">
			<h:panelGrid style="margin:auto;">
		EDITAR AGENTE
		</h:panelGrid>

		</div>

		<h:form id="formEdit">
			<h:panelGrid style="margin:auto;">

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:messages id="messages" ></p:messages>
				</h:panelGrid>

				<h:panelGrid columns="2" id="panelEdit">

					<h:panelGrid columns="2">

						<p:outputLabel value="Nombres"></p:outputLabel>
						<p:inputText value="#{agentController.firstname}"
							id="firstname" style="width: 300px;" readonly="true"></p:inputText>

						<p:outputLabel value="Apellidos"></p:outputLabel>
						<p:inputText value="#{agentController.lastname}" id="lastname"
							style="width: 300px;" readonly="true"></p:inputText>

						<p:outputLabel value="DNI"></p:outputLabel>
						<p:inputText value="#{agentController.documentNumber}"
							id="documentNumber" style="width: 300px;" readonly="true"></p:inputText>
							
						<p:outputLabel value="Usuario"></p:outputLabel>
						<p:inputText value="#{agentController.username}"
							id="username" style="width: 300px;" readonly="true" ></p:inputText>
						
						<p:outputLabel value="Activo"></p:outputLabel>
						<p:selectBooleanCheckbox value="#{agentController.isActive}" disabled="true"></p:selectBooleanCheckbox>	
						
						<p:outputLabel value="Code"></p:outputLabel>
						<p:inputText value="#{agentController.code}"
							id="code" style="width: 300px;"></p:inputText>			
							
						<p:outputLabel value="Supervisor"></p:outputLabel>
						<p:selectOneMenu id="supervisors"
							value="#{agentController.supervisorSelected}">
							<f:selectItem itemValue="" itemLabel="Seleccione..."></f:selectItem>
							<f:selectItems value="#{agentController.supervisors}"></f:selectItems>
						</p:selectOneMenu>	
						
						<p:outputLabel value="Auto Inicio"></p:outputLabel>
						<p:selectBooleanCheckbox value="#{agentController.autoready}"></p:selectBooleanCheckbox>
						
					</h:panelGrid>

					<h:panelGrid>
						<p:outputLabel value="Campañas"></p:outputLabel>
						<p:pickList value="#{agentController.campaignsAvailable}"
							var="campaign"
							itemLabel="#{campaign.substring(campaign.indexOf(124)+1,campaign.length())}"
							itemValue="#{campaign}">
							<p:ajax event="transfer" listener="#{agentController.onTransfer}" update=":formEdit:supervisors :formEdit:messages" />
							<f:facet name="sourceCaption">No Disponibles</f:facet>
							<f:facet name="targetCaption">Disponibles</f:facet>
						</p:pickList>
					</h:panelGrid>
				</h:panelGrid>

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:commandButton action="#{agentController.editAgent}"
						value="Editar" ajax="false">
					</p:commandButton>
				</h:panelGrid>
			</h:panelGrid>
		</h:form>
	</ui:define>

</ui:composition>
</html>
